#ifndef _GISUSDBIMPL_HXX_
#define _GISUSDBIMPL_HXX_

#include "mytypes.h"
#include <list>

class DB;
class GisusSWFileSet;
class FileLog;
class DBCache;
class Keyword;
class User;
class GisusDBImpl
{
 public:
  GisusDBImpl(DB *db, FileLog *filelog);
  ~GisusDBImpl();
  bool Connect();
  bool Disconnect();
  User* Login(const string &user, const string &pwd);
  int SaveTask(const Task* task);
  bool UpdateTask(const Task* task);
  bool MarkStatus(const Task* task, bool isZombie);
  int NewZombie(const Task* task);
  std::vector<Task*> GetZSeeds(Task::TaskStatus status);
  std::vector<Task*> LoadZombies(const Task* seed, int num);
  bool UpdateZombie(const Task* task);

  Task* GetTaskByCjh(const string& chj, const User* user);
  Task* GetNeighbor(const User* user, int curTaskId, bool next);
  std::vector<Task*> GetPTasks(const User* user, Task::TaskStatus status);
  bool DeleteTask(const string& cjh);
  bool RestoreBEndData(const User* user);
  bool LockDBTable(const string& table);
  bool UnlockDBTables(void);

  std::vector<Task*> GetYKTasks(void);

 private:
  DB *_db;
  FileLog *_filelog;
  DBCache *_dbcache;

};

#endif // _GISUSDBIMPL_HXX_
